You can create windows in two ways:
Creating windows from resources allows you to localize your application for different languages and to change the characteristics of your windows during application development by changing only the window resources.
All four functions, GetNewCWindow (GetNewCWindow) , GetNewWindow (GetNewWindow) , NewCWindow (NewCWindow) , and NewWindow (NewWindow) , can allocate space in your application's heap for the new window's window record. For more control over memory use, you can allocate the space yourself and pass a pointer when creating a window. In either case, the Window Manager fills in the data structure and returns a pointer to it.
Creates a color window with the properties defined in the 'WIND' resource with a specified resource ID.
pascal WindowPtr GetNewCWindow (short windowID,
void *wStorage,
WindowPtr behind);
The GetNewCWindow function creates a new color window from the specified window resource and returns a pointer to the newly created window record. You can use the returned window pointer to refer to this window in most Window Manager functions. If GetNewCWindow is unable to read the window or window definition function from the resource file, it returns nil .
The GetNewCWindow function looks for a 'wctb' resource with the same resource ID as that of the 'WIND' resource. If it finds one, it uses the window color information in the 'wctb' resource for coloring the window frame and highlighting selected text.
If the window's definition function (specified in the window resource) is not already in memory, GetNewCWindow reads it into memory and stores a handle to it in the window record. It allocates space in the application heap for the structure and content regions of the window and asks the window definition function to calculate those regions.
To create the window, GetNewCWindow retrieves the window characteristics from the window resource and then calls the NewCWindow function, passing the characteristics as parameters.
The GetNewCWindow function creates a window in a color graphics port. Before calling GetNewCWindow , verify that Color QuickDraw is available. Your application typically sets up its own global variables reflecting the system setup during initialization by calling the Gestalt function. See Inside Macintosh: Overview for more information about establishing the local configuration.
Note that the GetNewCWindow function returns a value of type WindowPtr , not CWindowPtr .
If you let the Window Manager create the window record in your application's heap, call DisposeWindow (DisposeWindow) to dispose of the window's window record. If you allocated the memory for the window record yourself and passed a pointer to the storage to GetNewCWindow , use the CloseWindow function (CloseWindow) to close the window and the Memory Manager routine DisposePtr to dispose of the window record.
For more information about window characteristics and the window resource, see NewCWindow NewCWindow and "The Window Resource" .
For more information about closing a window and removing the structures from memory, see the descriptions of the DisposeWindow function DisposeWindow , the CloseWindow function CloseWindow , and the DisposePtr function (documented in Inside Macintosh: Memory ).
Creates a new window from a window resource when Color QuickDraw is not available.
pascal WindowPtr GetNewWindow (short windowID,
void *wStorage,
WindowPtr behind);
The GetNewWindow function takes the same parameters as GetNewCWindow (GetNewCWindow) and returns a value of type WindowPtr . The only difference is that it creates a monochrome graphics port, not a color graphics port. The window record and graphics port record that describe monochrome and color graphics ports are the same size and can be used interchangeably in most Window Manager functions.
The GetNewWindow function creates a new window from the specified window resource and returns a pointer to the newly created window record. You can use the returned window pointer to refer to this window in most Window Manager functions. If GetNewWindow is unable to read the window or window definition function from the resource file, it returns nil .
If the window's definition function (specified in the window resource) is not already in memory, GetNewWindow reads it into memory and stores a handle to it in the window record. It allocates space in the application heap for the structure and content regions of the window and asks the window definition function to calculate those regions.
To create the window, GetNewWindow retrieves the window characteristics from the window resource and then calls the function NewWindow , passing the characteristics as parameters.
If you let the Window Manager create the window record in your application's heap, call DisposeWindow (DisposeWindow) to dispose of the window's window record. If you allocated the memory for the window record yourself and passed a pointer to the storage to GetNewWindow , use the CloseWindow function (CloseWindow) to close the window and the DisposePtr routine (documented in Inside Macintosh: Memory ) to dispose of the window record.
For more information about window characteristics and the window resource, see the descriptions of the NewWindow function NewWindow and "The Window Resource" .
For more information about closing a window and removing the structures from memory, see the descriptions of the DisposeWindow function DisposeWindow , the CloseWindow function CloseWindow , and the DisposePtr routine (documented in Inside Macintosh: Memory ).
Creates a window with a specified list of characteristics.
pascal WindowPtr NewCWindow (void *wStorage,
const Rect *boundsRect,
ConstStr255Param title,
Boolean visible,
short procID,
WindowPtr behind,
Boolean goAwayFlag,
long refCon);
The NewCWindow function actually calls the QuickDraw function OpenCPort to create the graphics port. The bitmap, pen pattern, and other characteristics of the window's graphics port are the same as the default values set by OpenCPort , except for the character font, which is set to the application font instead of the system font.
The NewCWindow function creates a window as specified by its parameters, adds it to the window list, and returns a pointer to the newly created window record. You can use the returned window pointer to refer to this window in most Window Manager functions. If NewCWindow is unable to read the window definition function from the resource file, it returns nil .
The NewCWindow function looks for a 'wctb' resource with the same resource ID as the 'WIND' resource. If it finds one, it uses the window color information in the 'wctb' resource for coloring the window frame and highlighting.
If the window's definition function is not already in memory, NewCWindow reads it into memory and stores a handle to it in the window record. It allocates space for the structure and content regions of the window and asks the window definition function to calculate those regions.
Storing the characteristics of your windows as resources, especially window titles and window items, makes your application easier to localize.
The NewCWindow function creates a window in a color graphics port. Creating color windows whenever possible ensures that your windows appear on color monitors with whatever color options the user has selected. Before calling NewCWindow , verify that Color QuickDraw is available. Your application typically sets up its own set of global variables reflecting the system setup during initialization by calling the Gestalt function. See the chapter Inside Macintosh: Overview for more information about establishing the local configuration.
Note that the function NewCWindow returns a value of type WindowPtr , not CWindowPtr .
If you let the Window Manager create the window record in your application's heap, call DisposeWindow (DisposeWindow) to close the window and dispose of its window record. If you allocated the memory for the window record yourself and passed a pointer to NewCWindow , use the CloseWindow function (CloseWindow) to close the window and the DisposePtr function (documented in Inside Macintosh: Memory ) to dispose of the window record.
For more information about closing a window and removing the structures from memory, see the descriptions of the DisposeWindow function DisposeWindow , the CloseWindow function CloseWindow , and the DisposePtr routine (documented in Inside Macintosh: Memory ). The Gestalt function is described in the chapter "Gestalt Manager" of Inside Macintosh: Operating System Utilities.
Creates a new window with the characteristics specified by a list of parameters when Color QuickDraw is not available.
pascal WindowPtr NewWindow (void *wStorage,
const Rect *boundsRect,
ConstStr255Param title,
Boolean visible,
short theProc,
WindowPtr behind,
Boolean goAwayFlag,
long refCon);
The NewWindow function actually calls the QuickDraw function OpenPort to create the graphics port. The bitmap, pen pattern, and other characteristics of the window's graphics port are the same as the default values set by OpenPort , except for the character font, which is set to the application font instead of the system font. The coordinates of the graphics port's port boundaries and visible region are changed along with its port rectangle.
The NewWindow function takes the same parameters as NewCWindow and, like NewCWindow (NewCWindow) , returns a WindowPtr as its function result. The only difference is that NewWindow creates a window in a monochrome graphics port, not a color graphics port. The window record and graphics port record that describe monochrome and color graphics ports are the same size and can be used interchangeably in most Window Manager functions.
The NewWindow function creates a window as specified by its parameters, adds it to the window list, and returns a pointer to the newly created window record. You can use the returned window pointer to refer to this window in most Window Manager functions. If NewWindow is unable to read the window definition function from the resource file, it returns nil .
If the window's definition function is not already in memory, NewWindow reads it into memory and stores a handle to it in the window record. It allocates space for the structure and content regions of the window and asks the window definition function to calculate those regions.
Storing the characteristics of your windows as resources, especially window titles and window items, makes your application easier to localize.
If you let the Window Manager create the window record in your application's heap, call DisposeWindow (DisposeWindow) to close the window and dispose of its window record. If you allocated the memory for the window record yourself and passed a pointer to NewWindow , use the CloseWindow function (CloseWindow) to close the window and the DisposePtr function (documented in Inside Macintosh: Memory ) to dispose of the window record.
For more information about closing a window and removing the structures from memory, see the descriptions of the DisposeWindow function DisposeWindow , the CloseWindow function CloseWindow , and the DisposePtr function (documented in Inside Macintosh: Memory ).